package Application;

import java.util.ArrayList;

import comm.AppInterface;

public class RequestDbCrown extends Thread 
{
	
  ArrayList<SampleRequest> listRequest;
   
  private static RequestDbCrown instance;
	
  private RequestDbCrown()
  {
     super("ClientDbCrown");
     listRequest=new ArrayList<SampleRequest>();
     this.start();
  }
	
  public static RequestDbCrown getInstance()
  {
     if (instance==null) instance=new RequestDbCrown();
	   return instance;
  }
	
  public void run() 
  {
     while(1 != 2)
     {
	   
	   if (!listRequest.isEmpty()) 
       {
          SampleRequest request=listRequest.get(0); 
          request.GenerateRequest();
          listRequest.remove(0);
       }
     
       try {
		      sleep(Integer.parseInt(AppInterface.getPropertyByName("sleepdbRequest")));
	       } 
       catch (InterruptedException e) 
	       {
		      e.printStackTrace();
	       }
      }
   }
	
  public void makeRequest(String a, String b, String c)
  {
		SampleRequest request=new SampleRequest(a,b,c);
		listRequest.add(request);
  }


}
